class Solution(object):
    def plusOne(self, digits):
        """
        :type digits: List[int]
        :rtype: List[int]
        """
        carry = 1
        digits.reverse()
        for i in range(len(digits)):
            if carry==0: break
            digits[i]+=carry
            carry=0
            if digits[i]==10:
                carry=1
                digits[i]=0
        if carry==1: digits.append(1)
        digits.reverse()
        return digits

print(Solution().plusOne([9,9,9,9,9]))
